package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspSysLog;

public class ErspSysLogDao extends JActiveTable {
	public ErspSysLogDao() {
		this.setDBTableName("ersp_sys_log");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", String.valueOf(Sequence.getGuid()));
		AddField(new JActiveField("service_name", "service_name", ActiveField.ftString, 200));
		AddField(new JActiveField("method_name", "method_name", ActiveField.ftString, 200));
		AddField(new JActiveField("ipaddr", "ipaddr", ActiveField.ftString, 50));
		AddField(new JActiveField("method_argv", "method_argv", ActiveField.ftString, Integer.MAX_VALUE));
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));

		setDbKeyFields("id");
	}

	public int add(ErspSysLog vo) {
		setFieldValue("service_name", vo.getService_name());
		setFieldValue("ipaddr", vo.getIpaddr());
		setFieldValue("method_name", vo.getMethod_name());
		setFieldValue("method_argv", vo.getMethod_argv());
		return DBManager.ExecSQL(this.getSQL());
	}
}
